/**
 * ReportGear(2011)
 */
package com.reportgear.designer.gui.config;

import java.awt.Dimension;
import java.util.Map;

import javax.swing.ButtonGroup;
import javax.swing.JPopupMenu;
import javax.swing.JToolBar;

import com.reportgear.designer.gui.config.ui.DottedSeparatorUI;
import com.reportgear.designer.gui.config.ui.TwoDottedSeparatorUI;

/**
 * 分隔条
 * 
 * @version 1.0 2011-4-26
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class SeparatorDef extends ShortCut {
	public static final int DEFAULT_STYLE = 1;
	public static final int GROUP_STYLE = 2;
	public static SeparatorDef DEFAULT = new SeparatorDef(DEFAULT_STYLE);
	public static SeparatorDef GROUP_SEPARATOR = new SeparatorDef(GROUP_STYLE);
	private static final Dimension separatorDimension = new Dimension(6, 21);
	public int separatorStyle = DEFAULT_STYLE;

	public SeparatorDef(int style) {
		this.separatorStyle = style;
	}

	public boolean intercept2JPopupMenu() {
		return false;
	}

	public void intoJPopupMenu(JPopupMenu paramJPopupMenu) {
		paramJPopupMenu.addSeparator();
	}

	public boolean intercept2JToolBar() {
		return false;
	}

	public void intoJToolBar(JToolBar toolbar, Map<String, ButtonGroup> groupMap) {
		JToolBar.Separator separator = new JToolBar.Separator(separatorDimension);
		if (this.separatorStyle == DEFAULT_STYLE) {
			separator.setUI(new DottedSeparatorUI());
		} else if (this.separatorStyle == GROUP_STYLE) {
			separator.setUI(new TwoDottedSeparatorUI());
		}

		toolbar.add(separator);
	}

	public boolean isEnabled() {
		return true;
	}

	public void setEnabled(boolean enable) {
	}
}
